package cn.aylog.test;

import cn.aylog.demo.TryWithResource;
import org.junit.Test;

public class TryDemo {

    @Test
    public void run1() {
        // 会自动调用close方法
        try(TryWithResource twr = new TryWithResource();
            TryWithResource twr2 = new TryWithResource()
        ){
            System.out.println(twr);
        }catch (Exception e) {
            System.out.println(e);
        }finally {
            System.out.println("finally...");
        }
        System.out.println("finish...");
// 结果
//        close...
//        close...
//        finally...
//        finish...

    }

    @Test
    public void run2() {
        assert 1 == 2 : "表达式错误";
    }

}
